package com.fitzone.web.controller.admin;

import com.fitzone.common.context.UserContext;
import com.fitzone.common.result.Result;
import com.fitzone.common.utils.QRCodeUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "二维码管理")
@RequestMapping("/admin/qrcode")
@RequiredArgsConstructor
public class QRCodeController {
    private final RedisTemplate redisTemplate;
    /**
     * 生成二维码
     */
    @ApiOperation("生成二维码")
    @GetMapping("/getQrcode")
    public Result getQRCode() {
        String content = "/mini/auth/scanQrcode";
        String qrcode = QRCodeUtil.getBase64QRCode(content);
        redisTemplate.opsForValue().set("qrcode", qrcode);
        return Result.ok(qrcode);
    }
}
